/**
 * @author maulin
 */
dojo.provide("medryx.model.Patient");
dojo.require("medryx.model.Entity");
dojo.require("medryx.model.Visit");
dojo.require("medryx.orm.Property");
dojo.require("medryx.orm.Association");
dojo.require("medryx.util.StringUtils");

dojo.declare("medryx.model.Patient", medryx.model.Entity, {
    birthdate:new medryx.orm.Property(), //need to add a  string->date converter
    gender:new medryx.orm.Property(),
	medicalRecordNumber:new medryx.orm.Property(),
	mpi:new medryx.orm.Property(),
	
	
	//name:new medryx.orm.Component({componentClass:"medryx.model.Name"}) //TODO -- Component support in ORM
	encodedName:new medryx.orm.Property(),
	initials:new medryx.orm.Property(),
	
	getFullName:function() {
		this.fullName = medryx.util.StringUtils.decodeBase64(this.getEncodedName());
		this.getFullName = function() {
			return this.fullName;
		}
		return this.getFullName();
	},
	
	visit:new medryx.orm.Association({associationClass:"medryx.model.Visit"}),
	
	socialSecurityNumber:new medryx.orm.Property(),
	
	toString:function() {
		return this.fullName;
	},
	
	queries:[
	   {name:"AllPatients", query:{}, queryOptions:{properties:["encodedName", "initials", "visit"]}}
	]
});
